00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00034
00035 require_once (PATH_TO_ROOT."messaging/classes/class.messaging_view.inc.php");
00036
00037
00038 class MessagingNew extends MessagingView {
00039
00045 private $role;
00046
00051 public function __construct($messaging) {
00052
00053 parent::__construct($messaging);
00054 }
00055
00060 protected function initView() {
00061 if (isset($_SESSION["invisible"]) && $_SESSION["usergroup"] != ADMIN) {
00062 Output::errorMessage($this->translate->_("Als anonymer Benutzer haben Sie nicht die Moeglichkeit, private Nachrichten zu versenden.<br />Bitte registrieren Sie sich, falls noch nicht geschehen, und verwenden Sie Ihren normalen Zugang."), 1, false, true);
00063 return false;
00064 }
00065 else {
00066 if (isset($_GET["Empfaenger"])) $_POST["Empfaenger"] = $_GET["Empfaenger"];
00067
00068 if (isset($_POST["Reply_x"]) || isset($_POST["ReplyAll_x"]) || isset($_GET["replyTo"]))
00069 {
00070 if (isset($_GET["replyTo"]) && $_GET["id"] == strval(intval($_GET["id"]))) {
00071 switch ($_GET["replyTo"]) {
00072 case "announcement":
00073 $sql = "SELECT user_id, course_id, title, text, Vorname, Nachname ".
00074 "FROM announcements LEFT JOIN user ON user.ID=user_id ".
00075 "WHERE announcements.id='{$_GET['id']}'";
00076
00077 $announcement = $this->db->get_row($sql);
00078 if ($announcement->user_id != 3 && ($announcement->course_id == 0 || $_SESSION["usergroup"] == ADMIN || $this->db->get_var("SELECT courseID FROM user_course WHERE courseID='$announcement->course_id' AND userID='{$_SESSION['userid']}'") == $announcement->course_id)) {
00079 $_POST["Betreff"] = $this->translate->_("Mitteilung").": ".trim(html_entity_decode($announcement->title));
00080 $_POST["Nachricht"] = trim(html_entity_decode($announcement->text));
00081 $_POST["Empfaenger"] = $announcement->Nachname.", ".$announcement->Vorname.($this->messaging->sameNameUsers($announcement->user_id) ? ", $announcement->user_id" : "");
00082 }
00083 break;
00084
00085 case "forumpost":
00086 $sql = "SELECT Vorname, Nachname, posttext, threadtopic, categoryid, forum_post.userID ".
00087 "FROM forum_post, forum_thread, forum_board, user "."WHERE forum_post.threadid=forum_thread.threadid ".
00088 "AND forum_post.userID=user.ID "."AND forum_thread.boardid=forum_board.boardid ".
00089 "AND postid='{$_GET['id']}'";
00090
00091 $post = $this->db->get_row($sql);
00092 if ($post->userID != 3 && $post->userID != 0 && ($post->categoryid == 0 || $_SESSION["usergroup"] == ADMIN || $this->db->get_var("SELECT courseID FROM user_course WHERE courseID='$post->categoryid' AND userID='{$_SESSION['userid']}'") == $post->categoryid)) {
00093 $_POST["Betreff"] = $this->translate->_("Forumpost").": ".trim($post->threadtopic);
00094 $_POST["Nachricht"] = trim($post->posttext);
00095 $_POST["Empfaenger"] = $post->Nachname.", ".$post->Vorname.($this->messaging->sameNameUsers($post->userID) ? ", $post->userID" : ";");
00096 }
00097 break;
00098
00099 case "newsoftheday":
00100 if ($_GET["id"] != $_SESSION["course"]) {
00101 return false;
00102 } else {
00103 $sql = "SELECT userID, message, Vorname, Nachname, Name "."FROM news_of_the_day LEFT JOIN user ON userID=user.ID LEFT JOIN courses ON courseID=courses.ID "."WHERE courseID='{$_GET['id']}'";
00104 $notd = $this->db->get_row($sql);
00105 if ($notd->userID != 3) {
00106 $_POST["Betreff"] = $this->translate->_("News of the Day").": ".($_GET["id"] == 0 ? "Foyer" : $notd->Name);
00107 $_POST["Nachricht"] = trim(html_entity_decode($notd->message));
00108 $_POST["Empfaenger"] = $notd->Nachname.", ".$notd->Vorname.($this->messaging->sameNameUsers($notd->userID) ? ", $notd->userID" : "");
00109 }
00110 }
00111 break;
00112
00113 default:
00114 return false;
00115 }
00116 }
00117
00118 $_POST["Betreff"] = $this->translate->_("RE:")." ".$_POST["Betreff"];
00119 $author = explode(";", $_POST["Empfaenger"]);
00120 $author = $author[0];
00121 $author = explode(",", $author);
00122 $_POST["Nachricht"] = "[quote]\n[b]".trim($author[1]) ." ".trim($author[0]) ." ".$this->translate->_("schrieb").":[/b]\n".$_POST["Nachricht"]."\n[/quote]\n";
00123 }
00124 if (isset($_POST["Forward_x"]))
00125 {
00126 $_POST["Betreff"] = "".$this->translate->_("FW:")." ".$_POST["Betreff"];
00127 if ($_POST["Typ"] == "inbox") {
00128 $_POST["Nachricht"] = $this->translate->_("--- Weitergeleitete Nachricht ---").
00129 "\n".$_POST["Empfaenger"]." schrieb am ".
00130 date("d.m.y - H:i",$_POST["Datum"]).":\n\n".
00131 $_POST["Nachricht"].
00132 "\n--- Ende weitergeleitete Nachricht ---";
00133 }
00134 elseif ($_POST["Typ"] == "outbox") {
00135 $_POST["Nachricht"] = $this->translate->_("--- Weitergeleitete Nachricht ---").
00136 "\n".$_SESSION["Nachname"].", ".
00137 $_SESSION["Vorname"]." ".$this->translate->_("schrieb am")." ".
00138 $_POST["Datum"].":\n\n".
00139 $_POST["Nachricht"].
00140 "\n".$this->translate->_("--- Ende weitergeleitete Nachricht ---");
00141 }
00142 $_POST["Empfaenger"] = "";
00143 }
00144 $_POST["Betreff"] = isset($_POST["Betreff"]) ? Data::toHTML($_POST["Betreff"]) : "";
00145 $_POST["Nachricht"] = isset($_POST["Nachricht"]) ? Data::toHTML($_POST["Nachricht"]) : "";
00146
00147
00148 if (isset($_POST["selectedUser"])) {
00149 $recipients = array();
00150 if (trim($_POST["Empfaenger"]) != "") {
00151 $recipients = explode(";", $_POST["Empfaenger"]);
00152 }
00153 foreach($_POST["selectedUser"] as $userID) {
00154 $user = $this->db->get_row("SELECT Nachname, Vorname, ShortName FROM user WHERE ID='".Data::toMysql($userID) ."'");
00155 if (!$this->db->num_rows) continue;
00156 if ($this->messaging->sameNameUsers($userID)) {
00157 $recipients[] = "$user->Nachname, $user->Vorname, $user->ShortName";
00158 } else {
00159 $recipients[] = "$user->Nachname, $user->Vorname";
00160 }
00161 }
00162 $recipients = array_map("trim", $recipients);
00163 $_POST["Empfaenger"] = implode("; ", array_unique($recipients)).";";
00164 }
00165
00166
00167 $this->role = $this->messaging->getRole();
00168
00169 print_r($this->role);
00170
00171 if ($this->role) {
00172 if (empty($_POST["Betreff"])) $_POST["Betreff"] = $this->role->getSetting("messaging_subject", true);
00173 if (empty($_POST["Nachricht"])) $_POST["Nachricht"] = "\n\n\n".$this->role->getSetting("messaging_sig", true);
00174 }
00175
00176 }
00177 return true;
00178 }
00179
00184 protected function checkActions() {
00185
00186 if(isset($_POST['ReplyAll_x'])) {
00187 $_POST["Empfaenger"] = Data::toHTML($_POST['EmpfaengerAntwortAnAlle'], false);
00188 }
00189
00190
00191 if (isset($_POST["sendButton"]) || isset($_POST['previewButton'])) {
00192 echo "<table width=\"100%\" border=\"0\">";
00193 $ok = true;
00194 if (trim($_POST["Empfaenger"]) == "") {
00195 Output::errorMessage($this->translate->_("Bitte einen Empfaenger eingeben."));
00196 $ok = false;
00197 }
00198 if (trim($_POST["Betreff"]) == "") {
00199 Output::errorMessage($this->translate->_("Bitte einen Betreff eingeben."));
00200 $ok = false;
00201 }
00202 if (trim($_POST["Nachricht"]) == "") {
00203 Output::errorMessage($this->translate->_("Bitte einen Nachrichtentext eingeben."));
00204 $ok = false;
00205 }
00206
00207
00208 if(!$ok) {
00209 return true;
00210 }
00211
00212
00213 if (isset($_POST['previewButton'])) {
00214 $this->previewMessage($_POST["Empfaenger"], $_POST["Betreff"], $_POST["Nachricht"]);
00215 }
00216 else {
00217
00218 $_POST["Empfaenger"] = Data::gpcUnescape($_POST["Empfaenger"]);
00219 if ($this->messaging->sendMessage($_POST["Empfaenger"], $_POST["Betreff"], $_POST["Nachricht"], (int)isset($_POST["asEmail"]))) {
00220 unset($_POST["Empfaenger"], $_POST["Betreff"], $_POST["Nachricht"], $_POST["asEmail"]);
00221 }
00222 }
00223 echo "</table>";
00224 }
00225 return true;
00226 }
00227
00232 public function echoNewMessage() {
00233 if($this->execution) {
00234
00235 echo "<form id='writeNewMessage' method='post' action='".PATH_TO_ROOT.SCRIPT_NAME."'>
00236 <table class='tableBorder' width='100%'>";
00237 Output::echoTableHead(Output::getIcon("icon_mail", $this->translate->_("Neue Nachricht schreiben")) .$this->translate->_("Neue Nachricht schreiben"));
00238 if ($this->role) {
00239 $roleName = "<strong>".Data::toHTML($this->role->getName($_SESSION["gender"]), false) ."</strong>";
00240 echo "<tr><td colspan='2' class='message'>";
00241 printf($this->translate->_("Sie nehmen zur Zeit die Rolle %1\$s ein.<br />Wenn Sie eine private Nachricht verfassen, wird diese dem Empfaenger auch ausserhalb dieses Kurses unter Ihrem Rollennamen angezeigt."),$roleName);
00242 echo "<br /></td></tr>";
00243 }
00244 echo "<tr><td class='text12'>";
00245 echo Utilities::helpCode(667);
00246 echo "<label for='Empfaenger'>".$this->translate->_("Empfaenger <em>(Nachname, Vorname [, User-ID oder User-Kennung]; ...)</em>") ."<label/>";
00247 echo "<p class='pForm'><input type='text' autocomplete='off' name='Empfaenger' id='Empfaenger' onkeyup='startAutoSearchTimer(2);' onfocus='startAutoSearchTimer(2);' style='width: 99%;' value=\"".(isset($_POST["Empfaenger"]) ? Data::toHTML($_POST["Empfaenger"]) : "") ."\"/>
00248 <div id=\"messaging_autocompletion_div\"><a href='#' class='messaging_autosearch'></a></div>
00249 </p><br/>";
00250 echo Utilities::helpCode(668);
00251 echo "<label for='Betreff'>".$this->translate->_("Betreff")."<label/>";
00252 echo "<p class='pForm'><input type='text' name='Betreff' onfocus='hideAutoList(\"messaging_autocompletion_div\");' maxlength='255' style='width: 99%;' value=\"";
00253
00254 if(isset($_POST['Betreff']) && $_POST['Betreff'] != '') {
00255 echo $_POST['Betreff'];
00256 }
00257 else if(isset($_GET['Betreff']) && $_GET['Betreff'] != '') {
00258 echo $this->translate->_("Web-News").": ".$_GET['Betreff'];
00259 }
00260
00261 echo "\"/></p><br/>";
00262 echo Utilities::helpCode(666);
00263 echo "<label for='Nachricht'>".$this->translate->_("Nachricht")."<label/>";
00264 echo "<textarea name='Nachricht' id='mce' class='mceEditor' cols='50' rows='15' onclick='hideAutoList(\"messaging_autocompletion_div\");' style='width: 99%;'>";
00265
00266 if(isset($_POST["Nachricht"]) && $_POST['Nachricht'] != '') {
00267 echo $_POST["Nachricht"];
00268 }
00269 else if(isset($_GET['wn'])) {
00270 printf($this->translate->_("Folgende Web-News wird Ihnen von %1\$s %2\$s empfohlen"),$_SESSION['Vorname'], $_SESSION['Nachname']);
00271 echo ":\n\n[url=" . $_GET['url'] . "]" . $_GET['Betreff'] . "[/url]\n" . $_GET['source'] . "\n\n";
00272 }
00273
00274 echo "</textarea><br/>";
00275
00276 if ($_SESSION['usergroup'] == ADMIN || $_SESSION['usergroup'] == DOZENT) {
00277 echo "<p class='pForm'><input type='checkbox' name='asEmail' id='asEmail' value='0'".(isset($_POST["asEmail"]) && $_POST["asEmail"] == 1 ? " checked='checked'" : "") ."/> <label for='asEmail'>".$this->translate->_("Auch als eMail senden")."</label></p>";
00278 }
00279
00280 echo "<p><a href='javascript:toggleEditor(\"mce\");' title='WYSIWYG-Editor ein/aus'>Editor</a></p>";
00281 echo "</td></tr>";
00282 echo " <tr><td align='center' class='text12'>
00283 <p class='pForm'><input type='submit' name='sendButton' value='".$this->translate->_("Senden")."'/></p>
00284 <p class='pForm'><input type='submit' name='previewButton' value='".$this->translate->_("Vorschau")."'/></p>
00285 <p class='pForm'><input type='reset' name='resetButton' value='".$this->translate->_("Zurücksetzen")."'/></p>
00286 </td></tr>
00287 ";
00288 echo "</table>\n</form>";
00289 }
00290 }
00291
00301 public function previewMessage($recipient, $subject, $message) {
00302 $bbcode = new BBCode(false, true, true, true, true);
00303 $messageHighlighted = $bbcode->parse($message);
00304
00305 $date = $this->zendDate->get(Zend_Date::DATE_LONG)." ".$this->zendDate->get(Zend_Date::TIME_FULL);
00306
00307 echo "<table class='tableBorder' width='100%'>";
00308 Output::echoTableHead("Vorschau", 4);
00309 echo "<tr>
00310 <td style='width: 20%;'></td>
00311 <td class='tableCellDark' style='width: 50px;'><b>".$this->translate->_("Empfaenger")."</b></td>
00312 <td class='tableCellDark'>".Data::toHTML($recipient) ."</td>
00313 <td style='width: 20%;'></td>
00314 </tr>";
00315 echo "<tr>
00316 <td style='width: 20%;'></td>
00317 <td class='tableCellDark' style='width: 50px;'><b>".$this->translate->_("Betreff")."</b></td>
00318 <td class='tableCellDark'>".Data::toHTML($subject)."</td>
00319 <td style='width: 20%;'></td>
00320 </tr>";
00321 echo "<tr>
00322 <td style='width: 20%;'></td>
00323 <td class='tableCellDark' style='width: 50px;'><b>".$this->translate->_("Datum")."</b></td>
00324 <td class='tableCellDark'>".$date."</td>
00325 <td style='width: 20%;'></td>
00326 </tr>";
00327 echo "<tr>
00328 <td colspan='4'></td>
00329 </tr>";
00330 echo "<tr>
00331 <td class='tableCellDark' colspan='4' align='center'><b>".$this->translate->_("Nachricht")."</b></td>
00332 </tr>";
00333 echo "<tr>
00334 <td colspan='4'>".$messageHighlighted."</td>
00335 </tr>
00336 </table>";
00337 }
00338 }
00339 ?>